'use strict';

/**
 * Module dependencies.
 */
var passport = require('passport'),
		LocalStrategy = require('passport-local').Strategy,
		User = require('mongoose').model('User');

module.exports = function() {
	// Use local strategy
	passport.use(new LocalStrategy({
			usernameField: 'username',
			passwordField: 'password'
		},
		// this is the login function?
		function(username, password, done) {

			if (username==='13691951449' && password==='password') {
				return done(null , {name: 'joel' , another: 'where the f that came from?'});
			}
			else {
				return done(null , false , {
					message: 'LOGIN ERROR'
				})
			}

			/*
			User.findOne({
				username: username
			}, function(err, user) {
				if (err) {
					return done(err);
				}
				if (!user) {
					return done(null, false, {
						message: 'Unknown user or invalid password'
					});
				}
				if (!user.authenticate(password)) {
					return done(null, false, {
						message: 'Unknown user or invalid password'
					});
				}
				return done(null, user);
			});
			*/
		}
	));
};
